<template>
  <div class="app-container">
    <el-card class="content-edit">
      <div slot="header">添加车辆类型</div>
      <el-form ref="form" :model="form" label-width="120px">
        <el-form-item label="名称">
          <el-input v-model="form['name']"/>
        </el-form-item>
        <el-form-item label="座位数">
          <el-input-number v-model="form['seat']" :min="2"/>
        </el-form-item>
        <el-form-item label="备注">
          <el-input v-model="form['remark']" type="textarea" rows="3"/>
        </el-form-item>
        <el-form-item label="图片">
          <div class="image-box">
            <ws-upload-single-img v-model="form['icon']" :path="form['iconUrl']"/>
            <div class="image-remark">
              <div class="remarks"><span class="symbol">⁎</span>注：1. 图片单张大小支持1M一下,超过系统会自动压缩</div>
              <div class="remarks">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2. 分辨率要求375px*200px</div>
              <div class="remarks">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3. 支持的图片格式 .jpg、.jpeg、.png、</div>
            </div>
          </div>
        </el-form-item>
        <el-form-item>
          <el-button :loading="loading" type="primary" @click="onSubmit">提交</el-button>
          <el-button @click="$router.back()">取消</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
  export default {
    name: 'HomepageBannerAdd',
    data() {
      return {
        loading: false,
        form: {
          // 车辆类型标题
          name: '',
          //  权重
          orderNumber: null,
          // 图片
          icon: '',
          // 图片地址
          iconUrl: '',
          // 座位数
          seat: 2,
          // 备注
          remark: ''
        }
      }
    },
    mounted(){},
    methods: {
      // 提交
      onSubmit() {
        this.$refs.form.validate(valid => {
          if (valid) {
            this.loading = true;
            (async () => {
              const params = Object.assign({}, this.form);
              const result = await this.$service.applicationAddCarType(params);
              this.loading = false;
              if (result.code === 0) {
                this.$message.success('操作成功~');
                this.$router.back();
              } else {
                this.$message.error(result.msg);
              }
            })();
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      }
    }
  }
</script>

<style scoped>
  .page-select {
    width: 65%;
  }
</style>

